package cn.xcstudenth5.zhuocan.scollviewandwebview;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import io.github.kexanie.library.MathView;

/**
 * Created by 赵航 on 2020/7/17.
 * WeChat: zhao--hang--
 */
public class MathLoading extends Fragment {

    private View    mMathLayout;
    private MathView mFormulaOne;
    String tex = "This come from string. You can insert inline formula:" +
            " \\(ax^2 + bx + c = 0\\) " +
            "or displayed formula: $$\\sum_{i=0}^n i^2 = \\frac{(n^2+n)(2n+1)}{6}$$";
    String two = "<p>解：<span class=\\\"ql-formula\\\" data-value=\\\"\\\\left(2a\\\\right)^3.A=8a^5\\\\\\\\\\\\;8a^3.A=8a^5\\\\\\\\A=8a^5\\\\div8a^3\\\\\\\\A=a^2\\\">$$\\\\left(2a\\\\right)^3.A=8a^5\\\\\\\\\\\\;8a^3.A=8a^5\\\\\\\\A=8a^5\\\\div8a^3\\\\\\\\A=a^2$$</span> ． </p> \\n\\r<p>故选A．</p> \\n\\r<p>先计算积的乘方，再根据单项式乘以单项式的逆运算即可．</p> \\n\\r<p>本题考查了单项式乘以单项式，解题的关键是注意字母指数的变化．</p>";
    String three = "<div>在边长为a的正方形中挖去一个边长为b的小正方形（a＞b）（如图甲），把余下的部分拼成一个矩形（如图乙），根据两个图形中阴影部分的面积相等，可以验证（　　）</div><div><img src=\"http://xcimg.zhuocan.com.cn/02/201809/2/20181005094844775728.png\"><br></div>";

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        mMathLayout = inflater.inflate(R.layout.fragment_math_view, null);
        init(mMathLayout);
        return mMathLayout;
    }

    private void init(View schoolAviewssignment) {
        mFormulaOne = (MathView) mMathLayout.findViewById(R.id.formula_one);
        mFormulaOne.getSettings().setJavaScriptEnabled(true);//启用js
        mFormulaOne.getSettings().setBlockNetworkImage(false);//解决图片不显示
     //   mFormulaOne.setText(three);
        mFormulaOne.loadDataWithBaseURL(null,three, "text/html", "utf-8", null);
    }
}
